package com.itheima.server.controller;

import com.itheima.server.service.BaiduService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/baidu")
public class BaiduController {

    @Autowired
    private BaiduService baiduService;


    /**
     * 接口名称：上报地理信息
     * 接口路径：POST/baidu/location
     */
    @PostMapping("/location")
    public ResponseEntity updateLocation(@RequestBody  Map<String,String> paraMap){
        Double longitude = Double.valueOf(paraMap.get("longitude")); //经度
        Double latitude = Double.valueOf(paraMap.get("latitude")); //经度
        String addrStr = paraMap.get("addrStr"); //经度
        baiduService.updateLocation(longitude,latitude,addrStr);
        return ResponseEntity.ok(null);
    }
}
